package org.example.domain.strategy.service.rule.chain.impl;

import lombok.extern.slf4j.Slf4j;
import org.example.domain.strategy.service.armory.IStrategyDispatch;
import org.example.domain.strategy.service.rule.chain.AbstractRaffleChain;
import org.example.domain.strategy.service.rule.chain.factory.DefaultChainFactory;
import org.example.domain.strategy.service.rule.tree.factory.DefaultTreeFactory;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Slf4j
@Component("default")
public class DefaultLogicChain extends AbstractRaffleChain {

    @Resource
    protected IStrategyDispatch dispatch;
    @Override
    protected String ruleModel() {
        return DefaultChainFactory.logicModel.RULE_DEFAULT.getInfo();
    }

    @Override
    public DefaultChainFactory.strategyAwardVO logic(String userId, Long strategyId) {

        log.info("抽奖责任链-默认处理 useId:{} strategyId:{}",userId,strategyId);

         Integer awardId = dispatch.getRandomAwardId(strategyId);
        return  DefaultChainFactory.strategyAwardVO.builder()
                .awardId(awardId)
                .logicModel(ruleModel())
                .build();
    }
}
